home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Libraries / HDS 3.02 / HDSTEST / hdstest.c next >
Encoding:
C/C++ Source or Header  |  1993-10-02  |  4.3 KB  |  212 lines  |  [TEXT/MPS ]

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <fcntl.h>
  5. #include <time.h>
  6. #ifdef MAC
  7. #include <Events.h>
  8. #include <Files.h>
  9. #include <Memory.h>
  10. #endif
  11. #ifdef MPW
  12. #include <Strings.h>
  13. #endif
  14. #include "hds.h"
  15.  
  16. /* benchmark for HDS; developed from DS1-benchmark */
  17.  
  18. #define NUM        1000
  19. #define TFILE    "test.hds"
  20. #define TPSEC    (CLOCKS_PER_SEC*1.)
  21.  
  22. void main ()
  23. {
  24.     char *recsat = "RECORDDUMMY";
  25.     char *datsat = "DATENBLOCKDUMMY";
  26.     PAR field;
  27.     int i;
  28.     short ftypn[10], ftypd[10];
  29.     char buff[80];
  30.     unsigned long tcount;
  31.     long gd;
  32.     FILESPEC fs;
  33.     static char *descr[] = {"Variable string for everything"};
  34.  
  35.     unlink (TFILE);
  36.     fs.s = TFILE;
  37. #ifdef MAC
  38.     fs.vRefNum = 0;                                        /* this volume */
  39.     fs.parID = 0L;                                        /* home directory */
  40.     fs.creator = 'HDSM';
  41. #endif
  42.     printf ("Start of HDS benchmark\n");
  43.     hdscreat (&fs);
  44. /*    hdssec (); */
  45.     ftypn[0] = STRING_F;
  46.     ftypd[0] = STRING_F;
  47.     gd = hdscregd ("Normal", 1, ftypn, 1, ftypd, descr, descr);
  48.     hdscrerpgd (gd);
  49.     field.s = recsat;
  50.     hdsinsr (&field);
  51.  
  52.     printf ("%d x hdsinse ", NUM);
  53.     tcount = clock ();
  54.     for (i = 0; i < NUM; i++) {
  55.         hdsinse (&field);
  56.     }
  57.     printf ("%f\n", (clock() - tcount) / TPSEC);
  58.  
  59.     hdsfrst ();
  60.  
  61.     printf ("%d x hdsdown ", NUM);
  62.     tcount = clock ();
  63.     for (i = 0; i < NUM; i++) {
  64.         hdsdown ();
  65.     }
  66.     printf ("%f\n", (clock() - tcount) / TPSEC);
  67.  
  68.     hdsfrst ();
  69.  
  70.     printf ("%d x hdsinsd hdsdata hdsdown ", NUM);
  71.     field.s = datsat;
  72.     tcount = clock ();
  73.     for (i = 0; i < NUM; i++) {
  74.         hdsinsd (&field);
  75.         hdsdata ();
  76.         hdsdown ();
  77.     }
  78.     printf ("%f\n", (clock() - tcount) / TPSEC);
  79.  
  80.     hdsfrst ();
  81.  
  82.     printf ("%d x hdsdata hdsdata hdsdown ", NUM);
  83.     tcount = clock ();
  84.     for (i = 0; i < NUM; i++) {
  85.         hdsdata ();
  86.         hdsdata ();
  87.         hdsdown ();
  88.     }
  89.     printf ("%f\n", (clock() - tcount) / TPSEC);
  90.  
  91.     hdsfrst ();
  92.  
  93.     printf ("%d x hdsdata hdsdata ", NUM);
  94.     tcount = clock ();
  95.     for (i = 0; i < NUM; i++) {
  96.         hdsdata ();
  97.         hdsdata ();
  98.     }
  99.     printf ("%f\n", (clock() - tcount) / TPSEC);
  100.  
  101.     hdsfrst ();
  102.  
  103.     printf ("%d x hdsdown hdsup ", NUM);
  104.     tcount = clock ();
  105.     for (i = 0; i < NUM; i++) {
  106.         hdsdown ();
  107.         hdsup ();
  108.     }
  109.     printf ("%f\n", (clock() - tcount) / TPSEC);
  110.  
  111.     hdsfrst ();
  112.  
  113.     printf ("%d x hdsdown hdsnfld ", NUM);
  114.     field.s = buff;
  115.     tcount = clock ();
  116.     for (i = 0; i < NUM; i++) {
  117.         hdsdown ();
  118.         hdsnfld (&field);
  119.     }
  120.     printf ("%f\n", (clock() - tcount) / TPSEC);
  121.  
  122.     hdsfrst ();
  123.  
  124.     printf ("%d x hdscrer hdsinsr ", NUM);
  125.     field.s = recsat;
  126.     tcount = clock ();
  127.     for (i = 0; i < NUM; i++) {
  128.         hdscrerpgd (gd);
  129.         hdsinsr (&field);
  130.     }
  131.     printf ("%f\n", (clock() - tcount) / TPSEC);
  132.  
  133.     hdstop ();
  134.  
  135.     printf ("%d x hdsrght ", NUM);
  136.     tcount = clock ();
  137.     for (i = 0; i < NUM; i++) {
  138.         hdsrght ();
  139.     }
  140.     printf ("%f\n", (clock() - tcount) / TPSEC);
  141.  
  142.     hdstop ();
  143.  
  144.     printf ("%d x hdsrght hdsleft ", NUM);
  145.     tcount = clock ();
  146.     for (i = 0; i < NUM; i++) {
  147.         hdsrght ();
  148.         hdsleft ();
  149.     }
  150.     printf ("%f\n", (clock() - tcount) / TPSEC);
  151.  
  152.     hdstop ();
  153.  
  154.     printf ("%d x hdsrght hdsnfld ", NUM);
  155.     field.s = buff;
  156.     tcount = clock ();
  157.     for (i = 0; i < NUM; i++) {
  158.         hdsrght ();
  159.         hdsnfld (&field);
  160.     }
  161.     printf ("%f\n", (clock() - tcount) / TPSEC);
  162.  
  163.     hdstop ();
  164.     hdsrght ();
  165.  
  166.     printf ("%d x hdsdown hdsdel ", (NUM >> 1));
  167.     field.s = buff;
  168.     tcount = clock ();
  169.     for (i = 0; i < (NUM >> 1); i++) {
  170.         hdsdown ();
  171.         hdsdel ();
  172.     }
  173.     printf ("%f\n", (clock() - tcount) / TPSEC);
  174.     
  175.     hdsfrst ();
  176.     hdsrght ();
  177.  
  178.     printf ("%d x hdsinse ", NUM);
  179.     field.s = recsat;
  180.     tcount = clock ();
  181.     for (i = 0; i < NUM; i++) {
  182.         hdsinse (&field);
  183.     }
  184.     printf ("%f\n", (clock() - tcount) / TPSEC);
  185.     
  186.     hdsfrst ();
  187.     hdsrght ();
  188.  
  189.     printf ("%d x hdsinse ", NUM);
  190.     field.s = recsat;
  191.     tcount = clock ();
  192.     for (i = 0; i < NUM; i++) {
  193.         hdsinse (&field);
  194.     }
  195.     printf ("%f\n", (clock() - tcount) / TPSEC);
  196.  
  197.     hdsfrst ();
  198.     hdsdown ();
  199.     
  200.     printf ("%d x hdsdel ", (NUM >> 1));
  201.     field.s = buff;
  202.     tcount = clock ();
  203.     for (i = 0; i < (NUM >> 1); i++) {
  204.         hdsdel ();
  205.     }
  206.     printf ("%f\n", (clock() - tcount) / TPSEC);
  207.     
  208.     hdsclose ();
  209.     fflush (stdout);
  210.     exit (0);
  211. }
  212.